package com.cloudptt.api.product.func.media;

import android.content.Context;
import com.cloudptt.api.product.func.IFunc;
import com.cloudptt.api.product.log.Log;
import com.mcptt.config.model.McIdInfo;
import com.mcptt.config.model.BootStrapSvrInfo;

public class MediaFunc implements IFunc{

	public static String THIS_FILE= "Media";
	private Context ctx = null;

	private MediaBroadcast broadcast;
	public MediaFunc(Context ctx)
	{
		this.ctx = ctx;
		this.broadcast = new MediaBroadcast(ctx, this);
		
//		Intent intent = new Intent(ctx, SipService.class);
//		intent.putExtra(SipManager.EXTERA, "MediaBroadcast");
//		ctx.getApplicationContext().bindService(intent,
//				connection, Context.BIND_AUTO_CREATE);
	}

	public void setListener(EventListener listener) {
		this.broadcast.setlistener(listener);
	}
	
	
//	protected ISipService service;
//	private ServiceConnection connection = new ServiceConnection() {
//
//		@Override
//		public void onServiceConnected(ComponentName arg0, IBinder arg1) {
//
//			service = ISipService.Stub.asInterface(arg1);
//		}
//
//		@Override
//		public void onServiceDisconnected(ComponentName arg0) {
//			service = null;
//		}
//	};
	
//	public void headsetPlug( int whichone)
//	{
//		Log.d(THIS_FILE, "headsetPlug whichone = "+whichone);
//		try {
//			if (whichone == 1) {
//				service.setHeadsetMicphoneOn(true);
//				service.setSpeakerphoneOn(false);
//			} else {
//				service.setHeadsetMicphoneOn(false);
//				service.setMicrophoneMute(false);
//				service.setSpeakerphoneOn(true);
//			}
//		} catch (RemoteException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
	
//	public void noise()
//	{
//		Log.d(THIS_FILE, "noise");
//		if( service == null ){
//			Log.e( THIS_FILE, "service is null." );
//			return;
//		}
//		try {
//			service.setHeadsetMicphoneOn(false);
//			service.setMicrophoneMute(false);
//			service.setSpeakerphoneOn(true);
//		} catch (RemoteException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
	
	@Override
	public void onLogined(McIdInfo mcIdInfo, BootStrapSvrInfo info, boolean isLoginSuc)
	{
	}
	@Override
	public void onPublishResult(int publishResult)
	{}
	@Override
	public void onSubscribeCmsGmsResult(boolean isSuc,int mcType)
	{}
	@Override
	public void doNetworkChange(boolean isConn)
	{
		Log.d(THIS_FILE, "doNetworkChange isConn = " + isConn);
	}
	@Override
	public void doForceDetach()
	{
		Log.d(THIS_FILE, "doForceDetach");
	}
	@Override
	public void doLogout()
	{
		Log.d(THIS_FILE, "doLogout");
	}
	@Override
	public void doExit()
	{
		this.broadcast.clearResource();
		
		this.ctx = null;
		this.broadcast = null;
	}

	@Override
	public void onLanChange(String lanType) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onKeepAlive(boolean isconnected) {
		// TODO Auto-generated method stub
		
	}
	
}
